//
//  THCPCTitleView.m
//  YJB
//
//  Created by 中电大维 on 2017/1/5.
//  Copyright © 2017年 YJB. All rights reserved.
//

#import "THCPCTitleView.h"

@implementation THCPCTitleView

- (instancetype)init
{
    if (self = [super init]) {
        _title = [[NSString alloc] init];
        [self addSubview:self.titleLabel];
        [self setLabelFrame];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    _titleLabel.text = _title;
}

- (void)setLabelFrame
{
    CGFloat titleWith = [NSString widthForString:@"广告网址:" fontSize:15 andHeight:15];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.mas_left).offset(12);
        make.height.mas_equalTo(16);
        make.width.mas_equalTo(titleWith);
    }];
}

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = [UIColor colorWithHexString:@"ff783c"];
        label.font = [UIFont systemFontOfSize:15];
        label.tag = 1;
        _titleLabel = label;
    }
    return _titleLabel;
}

@end
